import Vue from 'vue'
import VueRouter from 'vue-router'

// 重复点击导航时，控制台出现报错 
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

import Main from '../views/Main'
// import User from '../views/User'
// import Home from '../views/Home'
// import Mall from '../views/Mall'
// import pageOne from '../views/other/pageOne'
// import pageTwo from '../views/other/pageTwo'
import Login from '../views/Login'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Main',
        component: Main,
        redirect: '/home',
        children: [
            // {
            //     path: '/home',
            //     name: 'home',
            //     component: Home
            // },
            // {
            //     path: '/user',
            //     name: 'user',
            //     component: User
            // },
            // {
            //     path: '/mall',
            //     name: 'mall',
            //     component: Mall
            // },
            // {
            //     path: '/page1',
            //     name: 'page1',
            //     component: pageOne
            // },
            // {
            //     path: '/page2',
            //     name: 'page2',
            //     component: pageTwo
            // }
        ]
    },
    {
        path: "/login",
        name: "login",
        component: Login
    }
]

const router = new VueRouter({
    mode: 'history',
    routes
})

export default router